﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DeansWsccProject
{
    public partial class list : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["tag"] == null || Request.Params["tag"] == "") // do this if no tag in querystring
            {
                SqlDataSource1.SelectCommand = "SELECT [eBookTitle], [eBookImage], [eBookReleaseDate], [ID], [eBookRating] FROM eBooks"; // show all ebooks in ebooks table
            }
            else
            {
                SqlDataSource1.SelectCommand = "SELECT DISTINCT [eBookTitle], [eBookImage], [eBookReleaseDate], [ID], [eBookRating] FROM [eBookTagView] WHERE ([tag] = ?)"; // show ebooks filtered by tag from eBooksTagView
            }
        }
    }
}